add encoding test for travis builds.
authortsteven4 <tsteven4@gmail.com>
Sat, 4 Nov 2017 20:36:44 +0000 (14:36 -0600)
committertsteven4 <tsteven4@gmail.com>
Sat, 4 Nov 2017 20:36:44 +0000 (14:36 -0600)
.travis.yml
build_and_test
test_encoding [new file with mode: 0755]

index de45387ef3ef0678f3b8c85001660f412c54de88..15f3858e8eabcfeaf24df4b36c14efa87b3c1e60 100644 (file)
@@ -20,6 +20,14 @@ addons:
     - libusb-dev
     - docbook-xml
     - docbook-xsl
+before_script:
+# get locale needed for test_encoding.
+# these commands seem to work on xenial
+#  - sudo sed -i 's/^# *\(en_US ISO-8859-1\)/\1/' /etc/locale.gen
+#  - sudo dpkg-reconfigure --frontend=noninteractive locales
+# but on trusty it took something different, including eating an error from local-gen.
+  - sudo locale-gen en_US ISO-8859-1 || sudo locale-gen
+  - locale -a
 script:
  - ./build_and_test
 # TODO: build mac
index 1f391862455aa852985ffcd746ed1f88d181f5f6..2c37da12b858b2fe4009705f64cc135117426308 100755 (executable)
@@ -31,6 +31,8 @@ make linux-gui
 make doc
 make gpsbabel.html
 make check
+# test for mangled encoding of command line arguments
+./test_encoding
 #make torture
 rm -f vg.log
 ./vtesto -l -j vg.log
diff --git a/test_encoding b/test_encoding
new file mode 100755 (executable)
index 0000000..cabe47f
--- /dev/null
@@ -0,0 +1,37 @@
+#!/bin/bash
+# this file should be encoded in latin1
+
+BASEPATH=`dirname $0`
+PNAME=${PNAME:-${BASEPATH}/gpsbabel}
+REFERENCE=${BASEPATH}/reference
+
+TMPDIR=${GBTEMP:-/tmp}/gpsbabel.$$
+mkdir -p $TMPDIR
+trap "rm -fr $TMPDIR" 0 1 2 3 15
+
+errorcount=0
+
+if  locale -a | grep -q en_US.iso88591 ; then
+  export LC_ALL=en_US.iso88591
+  rm -f ${TMPDIR}/file*.kml
+  rm -f ${TMPDIR}/file*.gpx
+
+# test input file name mangling
+  cp ${REFERENCE}/bounds-test.gpx ${TMPDIR}/file¢.gpx
+  ${PNAME} -i gpx -f ${TMPDIR}/file¢.gpx -o kml -F ${TMPDIR}/fileo.kml || {
+    echo "ERROR: The input file name was mangled."
+    errorcount=`expr $errorcount + 1`
+  }
+
+# test output file name mangling
+  ${PNAME} -i gpx -f ${REFERENCE}/bounds-test.gpx -o kml -F ${TMPDIR}/file¢.kml
+  count=$(ls -1 -l ${TMPDIR}/file¢.kml | wc -l)
+  if [ $count -lt 1 ]; then
+    echo "ERROR: The output file name was mangled."
+    errorcount=`expr $errorcount + 1`
+  fi
+else
+  echo "$0 cannot run without the en_US.iso88591 locale."
+fi
+
+exit $errorcount